#!/bin/sh

# Purpose			: Shell script that allow easy use of terminal modification with Colored echo utilities
# Date/Time			: Wed Mar 14 11:41:22 IST 2012
# Modification Date	:

colored()
{
	if [ $TERM == "yes" ]; then
		echo -en "\\033[$1m"; 
	else
		echo -en ""; 
	fi		
}

BOLD=1
UNDERLINE=4
REVERSE=7
RED=31
GREEN=32
YELLOW=33
BLUE=34
PURPLE=35
VIOLET=35
CYAN=36
GREY=37
BLACK=39

if [ `tty | grep dev` ]; then
	TERM=yes
else
	TERM=no
fi

while test "$1" != ""
do
	case $1	in
	[0-9]*)		colored $1;
				shift;;
	-normal)	colored 0;
				shift;;
	-bold)		colored $BOLD;
				shift;;
	-underline)	colored $UNDERLINE;
				shift;;
	-reverse)	colored $REVERSE;
				shift;;
	-red)		colored $RED;
				shift;;
	-green)		colored $GREEN;
				shift;;
	-yellow)	colored $YELLOW;
				shift;;
	-blue)		colored $BLUE;
				shift;;
	-purple)	colored $PURPLE;
				shift;;
	-violet)	colored $VIOLET;
				shift;;
	-cyan)		colored $CYAN;
				shift;;
	-grey)		colored $GREY;
				shift;;
	-black)		colored $BLACK;
				shift;;
	*)			echo $*;
				if [ $TERM == "yes" ]; then
					colored 0; 
				fi
				exit;;
	esac
done

colored 0
